﻿using System.Diagnostics;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Editor.XNA
{
    class RenderWindow : Editor.GraphicsDeviceControl
    {

        Stopwatch timer;
        ContentManager content;
        SpriteBatch theBatch;
        Texture2D elite;

        // Vertex positions and colors used to display a spinning triangle.


        public Color BackgroundColor;
        /// <summary>
        /// Initializes the control.
        /// </summary>
        /// 
        protected override void Initialize()
        {


            timer = Stopwatch.StartNew();
            BackgroundColor = Color.Black;
            content = new ContentManager(Services, "Content");
            theBatch = new SpriteBatch(GraphicsDevice);
            elite = content.Load<Texture2D>("Elite");
            int j = 2;
            // Hook the idle event to constantly redraw our animation.
            Application.Idle += delegate { Invalidate(); };
        }


        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw()
        {
            // Spin the triangle according to how much time has passed.
            float time = (float)timer.Elapsed.TotalSeconds;

            GraphicsDevice.Clear(BackgroundColor);

            theBatch.Begin();
            theBatch.Draw(elite, new Vector2(20, 20), Color.White);
            theBatch.End();

            // Set renderstates.
            // GraphicsDevice.RenderState.CullMode = CullMode.None;    

        }

        /// <summary>
        /// Disposes the control, unloading the ContentManager.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                content.Unload();
            }

            base.Dispose(disposing);
        }


    }
}
